package org.aplikator.client.shared.descriptor;

import org.aplikator.client.local.widgets.ComboBoxWidget;
import org.aplikator.client.local.widgets.HasFields;

import com.google.gwt.user.client.ui.Widget;
import org.jboss.errai.common.client.api.annotations.Portable;

@SuppressWarnings("serial")
//@JsonTypeName("combo")
//@Portable
public class ComboBoxDTO  extends WidgetPropertyDTOBase implements RenderWidgetAware {

	public static final String TYPE_KEY = "combo";

    @SuppressWarnings("unused")
    public ComboBoxDTO() {       //TODO custom marshaller
    }

    public ComboBoxDTO(PropertyDTO  property) {
        super(property);
    }

    @Override
    public Widget getWidget(HasFields form) {
        ComboBoxWidget field = new ComboBoxWidget(property.getLocalizedName(), property, getSize());
        field.setEnabled(isEnabled());
        if (property.getRefferedThrough() != null) {
            field.setEnabled(false);
        }
        form.registerDataField(field);
        return field;
    }
}
